﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Loading</title>

    <style>
        @-webkit-keyframes ball-scale-ripple-multiple {
            0% {
                -webkit-transform: scale(0.1);
                transform: scale(0.1);
                opacity: 1;
            }

            70% {
                -webkit-transform: scale(1);
                transform: scale(1);
                opacity: 0.7;
            }

            100% {
                opacity: 0.0;
            }
        }

        @keyframes ball-scale-ripple-multiple {
            0% {
                -webkit-transform: scale(0.1);
                transform: scale(0.1);
                opacity: 1;
            }

            70% {
                -webkit-transform: scale(1);
                transform: scale(1);
                opacity: 0.7;
            }

            100% {
                opacity: 0.0;
            }
        }

        .ball-scale-ripple-multiple {
            position: relative;
            -webkit-transform: translateY(-25px);
            -ms-transform: translateY(-25px);
            transform: translateY(-25px);
        }

            .ball-scale-ripple-multiple > div:nth-child(0) {
                -webkit-animation-delay: -0.2s;
                animation-delay: -0.2s;
            }

            .ball-scale-ripple-multiple > div:nth-child(1) {
                -webkit-animation-delay: 0s;
                animation-delay: 0s;
            }

            .ball-scale-ripple-multiple > div:nth-child(2) {
                -webkit-animation-delay: 0.2s;
                animation-delay: 0.2s;
            }

            .ball-scale-ripple-multiple > div:nth-child(3) {
                -webkit-animation-delay: 0.4s;
                animation-delay: 0.4s;
            }

            .ball-scale-ripple-multiple > div {
                -webkit-animation-fill-mode: both;
                animation-fill-mode: both;
                position: absolute;
                top: 0;
                left: 0;
                width: 50px;
                height: 50px;
                border-radius: 100%;
                border: 2px solid #279fcf;
                -webkit-animation: ball-scale-ripple-multiple 1.25s 0s infinite cubic-bezier(.21, .53, .56, .8);
                animation: ball-scale-ripple-multiple 1.25s 0s infinite cubic-bezier(.21, .53, .56, .8);
            }
        .base{
            left: 50%;
            margin-top: -70px;
            position: absolute;
            top: 50%;
            margin-left: -40px;
        }
    </style>

</head>

<body>
    <div class="base">
        <div class="loader">
            <div class="loader-inner ball-scale-ripple-multiple">
                <div></div>
                <div></div>
                <div></div>
            </div>
        </div>
    </div>
    <script src="js/libs/jquery-2.1.1.min.js"></script>
    <script>
        var apiurl = "https://localhost:44301/api/"
        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return "";
        }

        var oauth = GetQueryString("state");
        var code = GetQueryString("code");
        if (oauth != "" && code !="") {
            var token = localStorage.token;

            $.ajax({
                headers: {
                    "Authorization": "bearer " + token
                },
                type: "post",
                url: apiurl + "OAuth/" + oauth + "?code=" + code,
                dataType: 'json',
                complete: function (e) {
                    console.log(e);
                    if (e.status != 200) {
                        alert("HTTP请求错误[" + e.status + "]" + e.statusText);
                    } else {
                        if (e.responseJSON.status.code == 0) {
                            localStorage.token = e.responseJSON.result.token;
                            top.location.href = sessionStorage.fromUrl || "index.html";
                        } else {
                            alert(e.responseJSON.status.msg + "[ERROR CODE:" + e.responseJSON.status.code + "]");
                        }
                    }
                }
            });
        }

    </script>

</body>
</html>